package myjava;

public class Main {

    public static void main(String[] args) {
	// write your code here

    tran();
    shoot();
    }
    public static void shoot(){
        Shoot s= new Shoot();
        try{
            s.pop();
        }catch (NegativeArraySizeException e){
            System.out.println("pop() 负数 is dected.");
        }
    }

    public static void tran(){
        Tran a =new Tran();
        try {
            int result=a.avg(102,105);
            System.out.println(result);
        }catch (MyExecption e){ //捕获 throw new MyExecption
            System.out.println(e);
        }
    }


}

class  MyExecption extends Exception{
    public MyExecption(String ErrorMessage){
        super(ErrorMessage); //作用于Exception的EM消息
    }
}
class Tran{
    public int avg( int a,int b) throws MyExecption{
        if (a <0 || b <0){
            throw new MyExecption ("fushu"); //抛出异常
        }
        if (a>100 || b>100){
            throw new MyExecption("too big");
        }
        return (a+b)/2;

    }

}


class Shoot{ //构建一个负数数组，来捕获该错误。
    static void pop() throws NegativeArraySizeException{
        int [] arr=new int[-1];
    }
}